﻿Namespace Catalog
    Public Class Genre
        Inherits BaseObject
        Public Property Subgenres As List(Of BaseObject)

        Public Sub New()
            Me.Subgenres = New List(Of BaseObject)
        End Sub

        Public Sub New(id As Integer, name As String, slug As String)
            Me.New()
            Me.ID = id
            Me.Name = name
            Me.Slug = slug
        End Sub

        Public Shared Function FromBPObject(gen As Catalog.BPOGenre) As Catalog.Genre
            If gen Is Nothing Then Return Nothing
            Dim newGenre As New Genre()

            newGenre.ID = gen.id
            newGenre.Name = gen.name
            newGenre.Slug = gen.slug

            For Each sg As BPOSubGenre In gen.subgenres
                Dim newBase As New BaseObject()
                newBase.ID = sg.id
                newBase.Name = sg.name
                newBase.Slug = sg.slug
                newGenre.Subgenres.Add(newBase)
            Next

            Return newGenre
        End Function
    End Class
End Namespace